A low-cost system for monitoring pH, dissolved oxygen and algal density in continuous culture of microalgae

Graphical abstract

ically demonstrated in Fig. 1. As can be seen that the system includes a culture tank, which is also known as a growth chamber. The culture tank is sequentially supplemented the nutrients through the fresh medium from the nutrition tank by Pump 1 whenever density of the microalgae in the growth chamber reaches to a preset threshold. Since microalgae absorb the nutrition over time for their continuous growth, the nutrients in the cultivation tank gradually reduce and the supplement is necessary in a continuous mode. It is noted that when Pump 1 is operating, Valve 2 is also open, which allows some microalgae to be harvested through the overflowing solution.
In addition to the nutrient supplement, the culture tank is equipped a ventilation system that not only provides air for the photosynthesis of microalgae but also supplies oxygen to the growth solution. Moreover, a stirring mechanism is additionally deployed to generate a continuous flow of the solution in the culture chamber, preventing microalgae from being deposited on the tank bottom. Hardware of the proposed monitoring system is now delineated as follows.

Microalgal density monitoring
In order to observe density of microalgae in the culture tank, a microalgae density predict module was designed as can be seen in Fig. 1. The microalgal solution is pumped to the module by Pump 2 from the culture tank through Valve 3. In this design, a Kamoer peristaltic pump was chosen whose flow rate ranges from 5.2 ml to 90 ml per minute and a PURO-XD-12VDC solenoid valve. A schematic diagram of the microalgae density predict module is illustrated in Fig. 2. As can be seen that the module comprises three main components, a dark box, an image processor and a human machine interface (HMI).
Let it first describe the dark box as it plays a critical role in the design. The dark box contains a sample container 1 that is plastic-transparent and has cylinder shape with a diameter of 3.5 cm and a height of 6 cm. In the measuring mode, the microalgae solution is continuously pumped into the sample container through a 3 mm diameter pipe and then refluxed back to the culture tank. A low-cost Raspberry Pi camera is installed at one of the dark box walls. At a predefined sampling frequency, the camera constantly takes photos of algal microorganisms running through the plastic-transparent sample container 1. The dark box has dimensions of 18 cm Â 16.5 cm Â 14.5 cm, and the idea to design the box in the equipment is to prevent all external disturbances caused by uncertain natural light influencing on quality of the captured images. In order to provide light inside the box for operations of the camera, an artificial light source was designed by 4 aluminium white light emitting diode (LED) bars forming a square shape as demonstrated in Fig. 3. The bar has a LED chip with surface mounted diodes (SMD) of 5054. There are 3 white diodes equidistantly arranged on each 7.5 cm bar. The white diode can generate colorless daylight at 6500 K color temperature, where its luminous flux is in a range of 20-24 lm. Internal surface of the dark box is covered by smooth-textured white fomex limiting any light reflection and refraction in the box.
One issue to be noted is that if the LED bars are installed facing directly to the sample container, it causes reflection, refraction and high contrast, which leads to inaccurate representation of microalgal density in images. Thus, it was proposed to exploit the bounce technique, a well-known method in photography [17]. To implement the bounce technique in the proposed system, one first designed a reflector deployed at one wall of the dark box. The LED bars were then installed facing directly to the reflector as can be seen in Fig. 2. The arrangement enables the dark box to generate a soft and uniformly distributed light in it, which minimizes phenomena of contrast, shadow, reflection and refraction on the sample container, guaranteeing high quality of the captured images. It is also noticed that distances from the camera lens to the sample container and from the sample container to the artificial light source are about 8 cm and 1.5 cm, respectively. After being taken by the camera at resolution of 600 Â 800 pixels, the images are sent to the image processor, which is implemented on a Raspberry Pi 3 B + for preprocessing and training a learning model [18,19]. The model is then utilized to predict density of microalgae presenting in a specific microalgal image. The predicted microalgae density is finally used to control the nutrient supplement as well as schedule the harvesting and forwarded to a 7-inch WaveShare HMI for real-time observations.

pH and DO monitoring
Two other environmental parameters including pH and DO also plays a very critical role in the growth rate and productivity of microalgae [20][21][22]. For instance, most of microalgal species grow in the culturing environment with pH under 9.5 [20]. Hence, it is crucial to maintain this level in the microalgae chamber. On the other hand, if carbon dioxide in a cultivation medium above 31m:g À3 , biomass productivity of microalgae starts reducing. That is, a predefined level of DO in the culture environment is required to be controlled in order to mitigate any CO 2 increment.  To continuously and effectively monitor both pH and DO in the microalgae solution, a measuring equipment was designed as demonstrated in Fig. 1. The schematic diagram of this device is presented in Fig. 4. It can be clearly seen that both the pH and DO sensors are deployed in the sample container 2. In the measurement mode, the microalgae solution is pumped from the culture tank to the sample container 2 by Pump 3 through Valve 4. After finishing taking measurements, the sample solution is discharged through Valve 5, and fresh water is pumped into the container by Pump 4. In this design, the Kamoer peristaltic pump was chosen for Pump 3 and Pump 4 while the PURO-XD-12VDC solenoid valve was chosen for Valve 4 and Valve 5, respectively.
The raw measurements taken by the E-201-C pH and DFRobot DO sensors are sent to an Arduino Nano to interpret the real pH and DO values in the culture tank, which can be employed to control those parameters and display on the 7-inch WaveShare HMI for observations.

Design files summary
This section provides brief summaries of the design files that were developed for the monitoring system. All the files are uploaded to a repository and can be accessed in this link. However, the files are also available with the article as presented below. It is noted that only the design files relevant to the monitoring system including the microalgae density and pH and DO measurement units are provided. The other design files in the continuous culture model such as the culture tank, discharge tank, air and stirring mechanisms are beyond scope of this paper.

Dark box
As discussed in Section 2, the first component in the microalgae density measurement unit is the dark box. The box has two layers as can be seen in Fig. 5 where the external layer is made of mica while the internal one is made of smoothtextured white fomex to minimize any light reflection and refraction. The dimensions of the box are detailed in Fig. 6.
Another component in the dark box is the artificial light that is generated by the LED bars. In the design, the LED bars are mounted on a frame as illustrated in Fig. 7.

Image processor and HMI
In the design, a Raspberry Pi 3 B + was used as an image processor where the raw images captured by the camera are processed. A learning model is also trained on this Raspberry Pi 3 B + given the microalgae images, which is then utilized to predict density of the microalgae. As can be seen in Fig. 8a, the processor is connected to a low-cost Raspberry Pi OV5647 camera. The microalgae density, after being computed by the processor, is displayed on the HMI as shown in Fig. 8b. Morevover, the Raspberry Pi 3 B + is employed to control Pump 2, where the control signal is sent to the power actuator circuit in Fig. 9a. It is noted that two buttons BT1 and BT2 were also designed as can be seen in Fig. 8a to manually control Pump 2 and the camera.

Power gain and artificial light
As discussed in Section 2, in this design a Kamoer peristaltic pump was chosen for Pump 2 and a PURO-XD-12VDC solenoid valve as selected for Valve 3. These both actuators are run at + 12 VDC. Therefore, a 12 V -2 channels optocoupler relay was selected to supply power to them, as can be seen in Fig. 9a. The optocoupler also isolates the processor from the + 12 V source. It is noted that whenever Pump 2 operates, Valve 3 is opened simultaneously. The artificial light is generated by four aluminum white LED bars forming a square shape. Each 7.5-cm bar has three surface-mounted diodes of 5054, which operates at + 12 VDC, as illustrated in Fig. 9b.

Sample container 2
The first component in the pH and DO measurement unit is the sample container 2, whose dimension overview is shown in Fig. 10. In the design, mica material was used to fabricate the container. Other design details including the sensor positions, the solution and cleaning water tube inlets, the discharge tube outlet and the overflowing position are sketched in Fig. 11.

pH and DO sensors
The low cost E-201-C pH and DFRobot DO sensors are chosen in this study to measure pH and DO parameters. The measurement in these sensors is controlled by an Arduino Nano microcontroller as can be seen in Figs. 12 and 13a. In other  words, the microcontroller can switch the sensors on or off through two TIP122 transitors in Fig. 12. And the sensor output signals are directly sent to the microcontroller.

Sensor signal interpretation and actuator control
The pH and DO sensor signals are received and interpreted by the Arduino microcontroller to compute the pH and DO quantities in the culture tank, as demonstrated in Fig. 13a. Moreover, the microcontroller is also used to control Pump4, Pump 5, Valve 3 and Valve 5 through a 12 V -4 channels optocoupler relay during the measurement period as illustrated in Fig. 13b.

Software and firmware files
Apart from the CAD and electronic circuit files aforesaid, there are also some software and firmware files used to run on the Raspberry Pi 3 Model B + and upload to the Arduino microcontrollers for the control and calculations. For instance, the file Central control unit.ino can be used to upload to the Arduino Mega 2560 in the central control unit as shown in Fig. 14 to set up when the measurements can be taken. Since the Arduino Mega 2560 is connected to both the Raspberry Pi 3 Model B + and Arduino Nano in Fig. 13, the program is also employed to read the measurements of pH, DO and microalgal density for other purposes such as recording, controlling other actuators in the whole cultivation system or displaying for real-time observations. The other file pH DO measurement.ino is uploaded to the Arduino Nano as depicted in Fig. 13 for calibrating the DO sensor and interpreting the pH and DO measurements from the raw sensor signals.  On the other hand, the files Automatic mode interface.ui, Microalgae graph interface.ui, pH graph interface.ui and DO graph interface.ui are run on PyQt5 and Python installed on the Raspberry Pi 3 Model B + to compute and display the microalgal density, pH and DO on the HMI device. The file Main.py is run on the Raspberry Pi 3 Model B + and utilized to predict density of microalgae given their captured images. It is noted that while the microalgal density values are computed within the Raspberry Pi 3 Model B+, the pH and DO measurements are read by Arduino Mega 2560 from the Arduino Nano and transmitted to the Raspberry Pi 3 Model B + through the communication as can be seen in Fig. 14. The measurements are sent to the HMI from the Raspberry Pi 3 Model B + as shown in Fig. 8.
All these software and firmware files are also uploaded to the repository.

Bill of materials summary
Bills of materials that were purchased for the system are summarized in an Excel spreadsheet, which can be found in this link.

Build instructions
This section provides information of the required components and step-by-step instructions to build two measurement units to monitor the microalgal density and pH and DO parameters in an algae culture environment.    Assemble 01 80 mm U4 silicone pipe, 01 elbows 90 o U4 and 01 30 mm U4 silicone pipe to make a couple of the L shape pipes as illustrated in Fig. 15 D3. Connect these two L shape pipes to two male couplings 3-3 on top of the container lid.
Building steps: Fabricate the dark box and diode frame using the design information in Section 3.1.1. Cut 04 75 mm diode segments, where each segment has 3 diodes, from the diode SMDs 5054 bar. Install 04 75 mm diode SMDs 5054 bars on the diode frame. The results can be seen in Fig. 16a. Connect the diode segments together and then to the power as shown in Fig. 9b. Connect the Raspberry Pi camera OV5647 to the Raspberry Pi 3 Model B + as illustrated in Fig. 8a. Install the sample container 1 to the sample container base as shown in Fig. 16b.  Install the camera and diode frame to the dark box given the information provided in Section 3. Cover the lid of the dark box.  Fig. 8.

Building steps:
Fabricate the sample container 2 using the design information in Section 3.2.1. Following the diagram in Fig. 18, assemble the given pipes and reducers to form the supplying and discharging pipes to the sample container 2. Following the diagram in Fig. 17, assemble the given pipes, pump, valve and reducers to form the solution supply system to the sample container 2. Following the diagram in Fig. 19, assemble the given pipes, pump and reducers to form the cleaning water supply system to the sample container 2.
Use a 60 mm U8 silicone pipe to connect Input 1 in Fig. 18 to Valve output in Fig. 17. Use a 2000 mm U6 silicone pipe to connect Pump input in Fig. 17 to the culture tank. Use another 60 mm U8 silicone pipe to connect Input 2 in Fig. 18 to Output in Fig. 19. Use another 2000 mm U6 silicone pipe to connect Input in Fig. 19 to the cleaning water tank. Connect a PURO-XD -12VDC solenoid valve to Output 2 in Fig. 18. Then use a 1500 mm U8 silicone pipe to connect the valve to the discharge tank. Use another 1500 mm U8 silicone pipe to connect Output 1 in Fig. 18 to the discharge tank.

Building steps:
Connect the sensors to the transistors and resistors as shown in Fig. 12. Deploy the sensors in the sensor cages in the sample container 2 as presented in the design in Section 3.2.1. Connect the other ends of the resistors in Fig. 12 to the Arduino Nano CH340 in Fig. 13a. Connect the Arduino Nano CH340 to the Arduino Mega 2560 in Fig. 14 Fig. 13b. Upload the file pH DO measurement.ino to the Arduino Nano CH340. Connect power to the sensors, microcontroller, pumps and valves.

Calibrations
In order to operate the proposed monitoring system, it is required to calibrate the sensing modules. In fact, the pH, DO and microalgal density sensing modules were already calibrated and incorporated into the programs pH DO measurement.ino  and Main.py, and the monitoring system is ready to be used. Nevertheless, this section provides the calibration procedures for those sensing modules in cases when the monitoring system is reproduced, it can be recalibrated to ensure accuracy of measurements.

pH sensor calibration
The setup for calibrating both the pH and DO sensors is demonstrated in Fig. 20. In order to calibrate the pH sensor, the buffer solutions with standard pH values of 4.01, 7.00 and 10.01 were exploited. The sensor probe was sequentially dipped into the buffer solutions. The sensor output voltage was also sequentially recorded by a multimeter. From three pairs of the voltage and pH values, it showed that relationship between the voltage and the pH quantity is quite linear. Therefore, a straight line was fitted through three data points to form a linear equation presenting computation of pH values given the sensor output voltage (Volt) as follows, pH ¼ À6:0274 Ã Volt þ 22:236: ð1Þ The Eq. (1) has already been implemented in the program pH DO measurement.ino. Fig. 21.

DO sensor calibration
In contrast to the pH sensor, the purified water was used for calibrating the DO sensor. In the first step, an air pump was employed to continuously inflate the water for about 10 min so that the dissolved oxygen is saturated in the water. After the bubbles in the water disappeared, the DO sensor probe was dipped into the water. While holding the sensor inside the water, the water was slowly stirred without generating any new bubbles. A multimeter Was utilized to monitor the sensor output voltage. Once the voltage value is stabilized, a voltage value that is called a saturation point voltage was recorded. In the meantime, DO in the water was also measured by using a high accurate HI8043 DO meter, which is called saturated DO. Hence, DO value in future measurements can be calculated by the following equation given the sensor output voltage (Volt).
The Eq.
(2) has also been implemented in the program pH DO measurement.ino.

Microalgal density measurement calibration
In order to calibrate the microalgal density measurement unit, the manual direct microscopic method was employed. The microalgae solution Was first filled into the sample container 1, and an image of the microalgae was captured using the proposed monitoring system. A sample of 1 ml the same microalgal solution was then mixed with a drop of 1% -2% Lugol's iodine. By utilizing a micropipette, 3.2 ll of the mixed solution was filled in a haemocytometer chamber (Fuchs Rosenthal).
After about 1 min, all the microalgal cells were evenly distributed in the chamber. The haemocytometer chamber was then placed under a bright light microscope (Zeiss, USA) at Â10 objective. And the microalgae in 4/16 squares were counted. That is, the accurate density of the microalgae in the examined solution was known. This procedure Was repeated 129 times for 129 different microalgal solutions, which resulted in 129 microalgal images and 129 microalgal density values. Features from the images were extracted and then utilized to build a learning model, where the model inputs are the image features while the model output is the microalgal density value. The learned model has already been implemented in the program Main.py. In future measurements, once an image of microalgae is captured, the features of the image can be extracted and input into the learned model. The model then predicts the density of the microalgae presenting in the image.

Operation guideline
After fabricating, building and assembling the measurement units as discussed in Section 5, operate the monitoring system as follows.
Deploy the units to the continuous culture system as can be seen in Fig. 1. Supply power to the microcontrollers, Raspberry Pi 3 Model B+, camera, sensors, artificial light source, pumps and valves. Turn on the Arduino Mega 2560, Arduino Nano CH340, Raspberry Pi 3 Model B+, camera, HMI. Run the program Central control unit.ino on the the Arduino Mega 2560. Run the program pH DO measurement.ino on the Arduino Nano CH340. Run the program Main.py on the Raspberry Pi 3 Model B+. Run the program Automatic mode interface.ui on the Raspberry Pi 3 Model B+, then the interface will appear on the HMI with the real-time measurements for observations. After each measurement, the electrodes of the pH and DO sensors should be cleaned by the deionized water to ensure high accuracy in next measurements.

Automatic program explanation
Though the monitoring system is programmed to run in an automatic mode, this section provides explanations of how the programs run in a step-by-step manner for better operations.

How the microalgal density measurement unit works
Once a command is sent out from the program Central control unit.ino that requires the microalgal density measurement unit to measure density of microalgae, both Pump 2 and Valve 3 are turned on. The microalgae solution is pumped into the sample container 1. When the sample container 1 is filled up by the algal solution, Pump 2 is turned off and Valve 3 is closed, the camera captures an image of the sample container 1 as can be seen in Fig. 22. The image is then sent to the Raspberry Pi 3 Model B + for preprocessing. Features are also extracted on each image, which are then input into a learning model [18,19] to predict density of the microalgae captured in the image. Processing the microalgae image and predicting the microalgal density are manipulated by the program Main.py. The predicted results are sent to the HMI for displaying and the Arduino Mega 2560 for other purposes.

How the pH and DO measurement unit works
Similar to the microalgal density measurement unit, when the pH and DO measurements are requested, the microalgae solution is pumped from the culture tank until the sample container 2 is full. The pH and DO sensors are then turned on to take measurements where the sensor output signals are transmitted to the Arduino Nano CH340 for further processing. The raw signals from the sensors are interpreted by the program pH DO measurement.ino on the Arduino Nano CH340. The interpreted results are sent to the Arduino Mega 2560 for displaying and other purposes. Once the measurements are completed, the solution is discharged through Valve 5 and the cleaning water is pumped into the sample container 2 for cleaning the sensor electrodes.

Validation and characterization
In order to validate and characterize the proposed monitoring system, it was implemented in a continuous culture model, where the culture tank has dimensions of 600 mm Â 450 mm Â 1000 mm. In the culture tank, the microalgal strain named Chlorella vulgaris was cultivated. The setup of the continuous model for growth the microalgae is demonstrated in Fig. 23. When the monitoring system was run, the HMI interface for displaying the measurements was captured and the snapshot is illustrated in Fig. 24. It is noted that the HMI was also designed to operate and control some other systems in the continuous model such as ventilation, stirring, . . .which are beyond scope of this paper. Some results of the pH, DO and microalgal density measurements gathered by the designed monitoring system are summarized as follows. Table 1.

pH sensor validation
To verify the pH sensor, the experiments of deploying the monitoring system were conducted in two different solutions with known pH values of 4.01 and 7.00, respectively. For each solution, 10 measurements were collected and the results are summarized in Table 2. As compared with the known pH values, the errors of the measurements obtained by the proposed monitoring system are 0.012 (0.300%) and 0.014 (0.200%), respectively.

DO sensor validation
Similar to the pH sensor, the DO sensor in the proposed device was also evaluated in the different solutions. In each solution, while a measurement was taken by the developed equipment, another measurement obtained by HI8043 meter was also recorded for the comparison purpose. The measured results are tabulated in Table 3, where the errors between the results correspondingly obtained by the monitoring system and HI8043 meter are calculated accordingly. The mean error in eight measurements is 0.303 (3.800%).

Microalgal density validation
The microalgal density measurement unit was verified by conducting the experiments in 25 different microalgae solutions, where their corresponding density ground truths range from 10.5 to 42.3 million cells per ml. The ground truth of the microalgae density in each solution was obtained by the manual direct microscopic method as discussed in Section 6.1.3. For each solution, the unit captured 3 images, which were then interpreted into 3 microalgal density values by the monitoring system. The root mean square errors between the microalgae density interpretations and the ground truths were computed and summarized in a histogram as depicted in Fig. 25. On average, the measurement accuracy obtained by the developed device as compared with the ground truth is about 8.6% (AE1.8%).

Conclusions
The paper has provided a detailed design of a low-cost monitoring system that can be employed to observe pH, DO and microalgal density parameters in a continuous chamber of culturing microalgae. The hardware of the system has been described while its designed components have also been delineated. Moreover, instructions of how to build the device from the designed components have been presented; and the guideline on how to efficiently operate the proposed equipment has also been provided. All the design files and material bills are attached for the reproducing purpose.

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.